package com.example.test1.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.example.test1.bean.Channel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 段傅华 on 2018/12/13.
 */

public class VpAdapter2 extends FragmentStatePagerAdapter {
    private  List<Channel.DataBean.NewsChannelListBean> mTitles;
    private  ArrayList<Fragment> mFragments;

    public VpAdapter2(FragmentManager fm, ArrayList<Fragment> fragments, List<Channel.DataBean.NewsChannelListBean> titles) {
        super(fm);
        this.mFragments=fragments;
        this.mTitles=titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position).getChannelName();
    }
}
